<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$ci = &get_instance();
	$USER = $ci->user_entity->init('id',$ESCORT->getUserId());
 	 
	$next_element = $current_index = $prev_element = null;
	if(isset($_SESSION['totalRESULTsearch'])){
		$current_key_element = $ESCORT->getId();
		$next_key_element = interator_getNext($_SESSION['pagination_result'],$current_key_element);
		$prev_key_element = interator_getPrev($_SESSION['pagination_result'],$current_key_element);
		
		$tmp = ($next_key_element) ? array_values($_SESSION['pagination_result'][$next_key_element]) :array('');
		$next_element = $tmp[0];
		$tmp = array_keys($_SESSION['pagination_result'][$current_key_element]) ;
		$current_index = $tmp[0];
		$tmp = ($prev_key_element) ? array_values($_SESSION['pagination_result'][$prev_key_element]) :array('');
		$prev_element = $tmp[0];
	}
	$location = getLocationZoneOfEscort( $ESCORT->getId()); 
?>

<script type="text/javascript" src="<?php echo site_url().'media/js/videoplayer.js'?>"></script>

<?php if($pos == 'top'):?>
	<div class="background-images-slideshow-wrapper">
		<div class="carousel js background-images-slideshow">
			<ul>
				<?php $i=0;?>
				<?php foreach($ci->media_entity->getMediaByPermission($ESCORT->getId(),'public_top') as $item):?>
					<?php $MEDIA = $ci->media_entity->init('id', $item->id) ;?>
					<?php if($MEDIA->getType() == 'image'):?>
						<li rel="<?php echo $MEDIA->getId();?>">
							<?php if($MEDIA->getReview() == 1): ?>
								<?php $showIntro = true; 
										//echo thumb($MEDIA->getTargetFileImageTopPublic('big'), PUBLIC_TOP_W, PUBLIC_TOP_H, false);
										$altTitleArr = $this->media_entity->getAltAndTitleText( $MEDIA->id,$location );
			
										echo thumb(
												$MEDIA->getTargetFileImageTopPublic('big'), 
												PUBLIC_TOP_W, PUBLIC_TOP_H,false,
												$altTitleArr['alt'],
												$altTitleArr['title']
											);
								?>
								<?php //if( $ESCORT->getPublicLanguageIds() == 1):?>
									<div class="introduction-text">
										<a class="ui-dialog-titlebar-close ui-corner-all" href="javascript:void(0);" role="button">
											<span class="ui-icon ui-icon-closethick" style="position:absolute;top:0;right:0;">close</span>
										</a>
										<p>
										<?php 
											if($tmp = $ESCORT->getDescription(get_language_id(),$ESCORT->getId())){
												echo str_replace(PHP_EOL,'<br/>',$tmp); 
											}
										?>
										</p>
									</div>
								<?php //endif; ?>
							<?php else: ?>
								<?php 
									//echo thumb($MEDIA->getTargetFileImageTopPublic('thin'), TOP_THIN_W, TOP_THIN_H, false);
									$altTitleArr = $this->media_entity->getAltAndTitleText( $MEDIA->id,$location );
									echo thumb(
												$MEDIA->getTargetFileImageTopPublic('thin'), 
												TOP_THIN_W, TOP_THIN_H,false,
												$altTitleArr['alt'],
												$altTitleArr['title']
											);	
								?>
							<?php endif;?>	
						</li>
					<?php else: ?>
						<li rel="<?php echo $MEDIA->getId();?>" class="videoplscn">	
							<?php $MEDIA->setClickedNo( $MEDIA->getClickedNo() );$MEDIA->update();?>
							<?php echo playvideo($MEDIA->getTargetFile('video'),$MEDIA->getTargetFile('avatar'),PUBLIC_TOP_W, PUBLIC_TOP_H, $MEDIA->getId());?>
							
							<div class="cls-video-media-player">
								<div class="cls-video-media-player-padding">
									<div class="cls-btn-pre" rel="<?php echo $MEDIA->getId();?>" onclick="doToggleController(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
									<div class="cls-wrap-context1-controller" rel="<?php echo $MEDIA->getId();?>">
										<div class="cls-btn-play" rel="<?php echo $MEDIA->getId();?>" onclick="doPlayVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-pause" rel="<?php echo $MEDIA->getId();?>" onclick="doPauseVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-min-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doMinVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-range-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doChangeVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-max-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doMaxVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
									</div>
									<div class="cls-wrap-video-control" rel="<?php echo $MEDIA->getId();?>">
										<div class="cls-wrap-video-control-inner">
											<div class="cls-range-buffer-play" rel="<?php echo $MEDIA->getId();?>" onclick="doSeekVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
											<div class="cls-timer-display" rel="<?php echo $MEDIA->getId();?>">0:00/0:00</div>
										</div>
									</div>
								</div>
							</div>
							
							<?php //if( $ESCORT->getPublicLanguageIds() == 1):?>
								<div class="introduction-text">
									<a class="ui-dialog-titlebar-close ui-corner-all" href="javascript:void(0);" role="button">
										<span class="ui-icon ui-icon-closethick" style="position:absolute;top:0;right:0;">close</span>
									</a>
									<p>
									<?php 
										if($tmp = $ESCORT->getDescription(get_language_id(),$ESCORT->getId())){
											echo str_replace(PHP_EOL,'<br/>',$tmp); 
										}
									?>
									</p>
								</div>
							<?php //endif; ?>
						</li>
					<?php endif;?>
					<?php $i++; ?>
				<?php endforeach; ?>	
			</ul>
		</div>
		<?php if($i>1):?>
			<script type="text/javascript">
				$(document).ready(function(){
					$("div.background-images-slideshow").carousel({
						dispItems:1,
						pagination:true,
						nextBtn: null,
						prevBtn: null,
						//autoSlideInterval:5000
					});
					window.setInterval('centerAlign()',1000);
				});
				function centerAlign() {
					$w = ($('.background-images-slideshow-wrapper').width()-$('.background-images-slideshow-wrapper .carousel-pagination').width() )/2 ;
					$w = parseInt($w);
					$('.background-images-slideshow-wrapper .carousel-pagination').css({"position": 'absolute', "left":$w+"px"});
				}
			</script>
		<?php endif;?>
			<script type="text/javascript">
				$(document).ready(function(){
					$('.introduction-text .ui-icon-closethick').click(function(){
						$('.introduction-text').hide();
						$('#open-introduction-text').show();
					}); 
					$('#open-introduction-text').click(function(){
						$('.introduction-text').show();
						$('#open-introduction-text').hide();
					}); 
					
					$('.escort-close-box-info.ui-icon-closethick').click(function(){
						$('.escort-sheet-info-top-navigation').hide();
						$('#open-box-info-text').show();
						$(this).hide();
					}); 
					$('#open-box-info-text').click(function(){
						$('.escort-sheet-info-top-navigation').show();
						$('.escort-close-box-info').show();
						$('#open-box-info-text').hide();
					}); 
				});
			</script>
		<div class="escort-sheet-info-top-navigation">
			<div class="escort-sheet-info-phone">
				<a href="javascript:void(0);"><img src="{{url:base}}media/img/phone.png" /></a>
			</div>
			<div class="escort-navigation-wrapper">
				<div class="escort-name">
					<span class="name"><?php echo strtoupper($ESCORT->getEscortName());?></span>
					<span class="address"><?php echo language_translate('myzone_page_escort_in').' '.getLocationZoneOfEscort($ESCORT->getId());?></span>
				</div>
				<div class="escort-navigation">
					<?php if( $prev_element != '' ):?>
						<a href="<?php echo buildCustomProfileLink($prev_element,true);?>"><img src="{{url:base}}media/img/pre-buton.png" /></a>
					<?php endif;?>	
					
					<?php if( $next_element != '' ):?>
						<a href="<?php echo buildCustomProfileLink($next_element,true);?>"><img src="{{url:base}}media/img/next-button.png" /></a>
					<?php endif;?>	 
				</div>
				<div class="clear"></div>
				<div class="order-number">
					<?php if( $current_index != '' ):?>
						<span><?php echo $current_index;?> <?php echo language_translate('myzone_page_escort_of');?> <?php echo $_SESSION['totalRESULTsearch'];?></span>
					<?php endif;?>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		
		
		
		<!-- 
			<div class="escort-close-box-info ui-icon ui-icon-closethick"></div>
			<div id="open-box-info-text" title="<?php echo language_translate('myzone_page_open_introduction_text'); ?>">123</div>
		 -->
		<div id="open-introduction-text" title="<?php echo language_translate('myzone_page_open_introduction_text'); ?>">123</div>
	</div>
<?php endif; ?>

<div class="clear"></div>

<?php if($pos == 'bottom'):?>
	<div class="carousel js image-slideshow">
		<ul>
			<?php $i=0;?>
			<?php foreach($ci->media_entity->getMediaByPermission($ESCORT->getId(), 'public') as $item):?>
				<?php $MEDIA = $ci->media_entity->init('id',$item->id);?>
					<?php if($MEDIA->getType() == 'image'):?>
						<li rel="<?php echo $MEDIA->getId();?>">	
							<?php 
								//echo thumb($MEDIA->getTargetFileImagePublic(),PUBLIC_W,PUBLIC_H,false);
								$altTitleArr = $this->media_entity->getAltAndTitleText( $MEDIA->id, $location );
								echo thumb(
												$MEDIA->getTargetFileImagePublic(), 
												PUBLIC_W, PUBLIC_H,false,
												$altTitleArr['alt'],
												$altTitleArr['title']
											);	
							?>
						</li>
					<?php else:?>
						<li rel="<?php echo $MEDIA->getId();?>" class="videoplscn">	
							<?php echo playvideo($MEDIA->getTargetFile('video'),$MEDIA->getTargetFile('avatar'),PUBLIC_W,PUBLIC_H,$MEDIA->getId());?>
							
							<div class="cls-video-media-player">
								<div class="cls-video-media-player-padding">
									<div class="cls-btn-pre" rel="<?php echo $MEDIA->getId();?>" onclick="doToggleController(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
									<div class="cls-wrap-context1-controller" rel="<?php echo $MEDIA->getId();?>">
										<div class="cls-btn-play" rel="<?php echo $MEDIA->getId();?>" onclick="doPlayVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-pause" rel="<?php echo $MEDIA->getId();?>" onclick="doPauseVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-min-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doMinVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-range-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doChangeVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
										<div class="cls-btn-max-volumn" rel="<?php echo $MEDIA->getId();?>" onclick="doMaxVolumn(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
									</div>
									<div class="cls-wrap-video-control" rel="<?php echo $MEDIA->getId();?>">
										<div class="cls-wrap-video-control-inner">
											<div class="cls-range-buffer-play" rel="<?php echo $MEDIA->getId();?>" onclick="doSeekVideo(<?php echo $MEDIA->getId();?>);">&nbsp;</div>
											<div class="cls-timer-display" rel="<?php echo $MEDIA->getId();?>">0:00/0:00</div>
										</div>
									</div>
								</div>
							</div>
							
						</li>
					<?php endif;?>
				<?php $i++; ?>	
			<?php endforeach;?>
		</ul>
	</div>
	<div class="clear"></div>
	<div id="report_abuse">
		<?php echo language_translate('myzone_page_escort_report_abuse');?>
		<input type="text" name="report_abuse_link" id="report_abuse_link" value="<?php echo language_translate('myzone_page_escort_report_abuse_label');?>" />
		<div id="report_email_button"></div>
		<div id="report_loading"><?php echo loader_image_s('id="report_loading_image"');?></div>
	</div>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#report_abuse_link").focusin(function(){
				$name = "<?php echo language_translate('myzone_page_escort_report_abuse_label');?>";
				if($(this).attr("value") == $name){
					$(this).attr("value","");
				}
			}).focusout(function(){
				$name = "<?php echo language_translate('myzone_page_escort_report_abuse_label');?>";
				if("" ==$(this).attr("value") ){
					$(this).attr("value",$name);
				}
			});	

			$('#report_email_button').bind('click',function(){
				$report_abuse_link = $('#report_abuse_link').val();
				$('#report_abuse_link').removeClass('red-border');
				if(!isUrl($report_abuse_link)){
					$('#report_abuse_link').addClass('red-border');
					$('#report_abuse_link').attr('value','').focus();
					return false;
				}else{
					$('#report_loading_image').toggle();
					$.post(BASE_URI+'home/report_abuse',{link:document.location.href},function(res){
						if(res.result == 'ok'){
							$('#report_abuse').html('<span style="color:green;">'+res.msg+'</span>').fadeOut(10000);
						}
					},'json');
				}
			});
		});
	</script>
	<?php if($i>1):?>
		<script type="text/javascript">
			$(document).ready(function(){
				$("div.image-slideshow").carousel({
					dispItems:1,
					autoSlide:true,
					pagination:true,
					nextBtn: null,
					prevBtn: null		
				});
			});
			
		</script>
	<?php endif;?>
<?php endif; ?>

